import requests

# url = "http://httpbin.org/get?age=18"
#
# response = requests.get(url,params={'name':'qiku'} ,headers={
#     'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36'
# })
# print(response.status_code)
# if response.status_code == 200:
    # # result = response.text
    # result2 = response.json()
    # # print(result)
    # # print(result2)
    # result3 = result2['args']['name']
    # print(result3)


# url = "http://httpbin.org/post"
#
# data = {
# 'name':'qiku'
# }
# response = requests.post(url,data=data,headers={
#     'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
#     # 'content-type':'application/json', # 告诉服务器“我这次发来的数据是 JSON 文本”，而不是默认的表单格式
#     'content-type':'application/x-www-form-urlencoded'
# })
#
# result = response.json()
# result2 = result['headers']['Content-Type']
# print(result2)

import requests, os

url = 'https://pic.netbian.com/uploads/allimg/241218/221150-1734531110f399.jpg'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
    'Referer': 'https://pic.netbian.com/',
    'Accept': 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9'
}

response = requests.get(url, headers=headers, timeout=10)
print('status:', response.status_code)
if response.status_code == 200:
    os.makedirs('static', exist_ok=True)
    with open('static/pic.jpg', 'wb') as f:
        f.write(response.content)
    print('已保存为 static/pic.jpg')
else:
    print('仍失败', response.status_code)


